package org.prothlisberger.musicsearch.exporter;

import java.io.BufferedWriter;
import java.io.File;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.Iterator;

public class PlaylistMusicExporter implements IMusicExporter {

	public PlaylistMusicExporter() {

	}

	@Override
	public void export(Iterator<File> aFiles, OutputStream aOutputStream) {
		try (BufferedWriter vWriter = new BufferedWriter(new OutputStreamWriter(aOutputStream, "cp1252"))) {
			while (aFiles.hasNext()) {
				File vFile = aFiles.next();
				vWriter.write(vFile.getAbsolutePath());
				vWriter.write('\n');
			}
		} catch (Exception e) {
			throw new RuntimeException("erreur pendant l'export", e);
		}
	}

}
